

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  <script type="text/javascript" src="../../layuiadmin/js/system/jquery.min.js"></script>
  <script type="text/javascript" src="../../layuiadmin/js/system/jquery.cookie.js"></script>
  <script>
    var userid=$.cookie("redisId");
    $(function () {
      $("#ok").click(function () {
        var oldpwd = $("#oldPassword").val();
        var pwd = $("#password").val();
        var repassword = $("#repassword").val();
        $.post("http://localhost:8080/user/getPwd",
                {"oldpwd": oldpwd, "userid": userid},
                function (msg) {
                  if (msg == 200) {
                    if (pwd!= '' && pwd!= null) {
                      if (pwd == repassword) {
                        $.post("http://localhost:8080/user/updatePwd",
                                {"pwd": pwd, "userid": userid},
                                function (msg) {
                                  alert("修改成功,请重新登录！");
                                  top.location = '../login.html'
                                })
                      } else if (pwd == oldpwd) {
                        $("#oldpassdiv").html("");
                        $("#passdiv").html("新密码与旧密码相同，请重新输入");
                        $("#password").val("");
                      } else {
                        $("#passdiv").html("");
                        $("#repassdiv").html("两次新密码不相同，请重新输入");
                        $("#repassword").val("");
                      }
                    } else {
                      $("#passdiv").html("请输入新密码");
                    }
                  } else {
                    $("#repassdiv").html("")
                    $("#oldpassdiv").html("旧密码输入错误请重新输入");
                    $("#oldPassword").val("");
                  }
        });
      });
    });
  </script>
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">修改密码</div>
          <div class="layui-card-body" pad15>

            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="oldPassword" id="oldPassword" lay-verify="required" lay-verType="tips" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"id="oldpassdiv"></div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="password" id="password" lay-verify="pass" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"id="passdiv"></div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="repassword" id="repassword" lay-verify="repass" lay-verType="tips" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"id="repassdiv"></div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="setmypass" id="ok">确认修改</button>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="../../layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set']);
  </script>

</body>
</html>